const express = require('express')
const router = express.Router()
const multer = require('multer')
const upload = multer({ dest: 'uploads/' })
const uploadService = require('services/upload')
const config = require('config')

router.post('/', upload.single('file'), async (req, res, next) => {
  try {
    let result = await uploadService.upload(req.file.path)
    res.json(result) 
  } catch (e) {
    next(e)
  }
  // let result = await uploadService.upload(req.file)
  // res.json(result)
})

module.exports = router